package com.crocodileQ.blog.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.crocodileQ.common.annotation.Log;
import com.crocodileQ.common.core.controller.BaseController;
import com.crocodileQ.common.core.domain.AjaxResult;
import com.crocodileQ.common.enums.BusinessType;
import com.crocodileQ.blog.domain.BlogInteractions;
import com.crocodileQ.blog.service.IBlogInteractionsService;
import com.crocodileQ.common.utils.poi.ExcelUtil;
import com.crocodileQ.common.core.page.TableDataInfo;

/**
 * 互动管理Controller
 * 
 * @author crocodilePole
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/blog/article_interactions")
public class BlogInteractionsController extends BaseController
{
    @Autowired
    private IBlogInteractionsService blogInteractionsService;

    /**
     * 查询互动管理列表
     */
    @PreAuthorize("@ss.hasPermi('blog:article_interactions:list')")
    @GetMapping("/list")
    public TableDataInfo list(BlogInteractions blogInteractions)
    {
        startPage();
        List<BlogInteractions> list = blogInteractionsService.selectBlogInteractionsList(blogInteractions);
        return getDataTable(list);
    }

    /**
     * 导出互动管理列表
     */
    @PreAuthorize("@ss.hasPermi('blog:article_interactions:export')")
    @Log(title = "互动管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlogInteractions blogInteractions)
    {
        List<BlogInteractions> list = blogInteractionsService.selectBlogInteractionsList(blogInteractions);
        ExcelUtil<BlogInteractions> util = new ExcelUtil<BlogInteractions>(BlogInteractions.class);
        util.exportExcel(response, list, "互动管理数据");
    }

    /**
     * 获取互动管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('blog:article_interactions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(blogInteractionsService.selectBlogInteractionsById(id));
    }

    /**
     * 新增互动管理
     */
    @PreAuthorize("@ss.hasPermi('blog:article_interactions:add')")
    @Log(title = "互动管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlogInteractions blogInteractions)
    {
        return toAjax(blogInteractionsService.insertBlogInteractions(blogInteractions));
    }

    /**
     * 修改互动管理
     */
    @PreAuthorize("@ss.hasPermi('blog:article_interactions:edit')")
    @Log(title = "互动管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlogInteractions blogInteractions)
    {
        return toAjax(blogInteractionsService.updateBlogInteractions(blogInteractions));
    }

    /**
     * 删除互动管理
     */
    @PreAuthorize("@ss.hasPermi('blog:article_interactions:remove')")
    @Log(title = "互动管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(blogInteractionsService.deleteBlogInteractionsByIds(ids));
    }
}
